package com.crnn.smart.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IndexController {

    @RequestMapping(value = "/index",method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView getIndex(HttpServletRequest request){
        ModelAndView model = new ModelAndView();
        model.setViewName("index");
        return model;
    }

    @GetMapping("/show")
    public ModelAndView getshow(HttpServletRequest request){
        String path = request.getParameter("path");
        ModelAndView model = new ModelAndView();
        model.setViewName(path.substring(0,path.length()-5));
        return model;
    }

}
